package com.dhcc.bpm.business.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
 * 日期工具类
 *
 */
public class DateUtil {

	/**
	 * @Description:获取 格式为yyyyMMdd的日期
	 *
	 */
	public static String getSimpleDate() {
		return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
	}

	/**
	 * @Description: 获取 格式为HHmmss
	 *
	 */
	public static String getSimpleTime() {
		return LocalTime.now().format(DateTimeFormatter.ofPattern("HHmmss"));
	}
	/**
	 * @Description: 获取 格式为yyyyMMddHHmmss
	 *
	 */
	public static String getSimpleDateTime() {
		return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
	}
	/**
	 * @Description: 获取 格式为yyyy-MM-dd HH:mm:ss
	 *
	 */
	public static String getSimpleDateTime1() {
		return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
	}
	/**
	 * @Author wangjinghan
	 * @Description 给日期加 -
	 * @param:
	 * @return:
	 * @date: 2019/12/30 9:49
	 */
	public static String  ToDate(String date){
		String result = "";
		if (date.length()==8){
			String year = date.substring(0,4);
			String month = date.substring(4,6);
			String day = date.substring(6);
			result = year + "-" +month + "-" + day;
		}else{
			result = date;
		}
		return  result;
	}
}
